﻿namespace BootstrapBlazor.Components;

/// <summary>
/// 下拉按钮项
/// </summary>
public class DropdownButtonItem : NodeItem
{
    public DropdownButtonItem()
    {
        Id = Guid.NewGuid().ToString("N");
    }

    /// <summary>
    /// 普通按钮
    /// </summary>
    /// <param name="text">按钮显示值</param>
    /// <param name="click">按钮单击事件</param>
    public DropdownButtonItem(string text, Func<Task> click) : this()
    {
        Text = text;
        OnConfirm = click;
    }

    /// <summary>
    /// 普通按钮
    /// </summary>
    /// <param name="icon">实际按钮渲染图标</param>
    /// <param name="text">按钮显示值</param>
    /// <param name="click">按钮单击事件</param>
    public DropdownButtonItem(string icon, string text, Func<Task> click)
        : this(text, click)
        => Icon = icon;

    /// <summary>
    /// 确认弹窗按钮
    /// </summary>
    /// <param name="text">按钮显示值</param>
    /// <param name="confirm"></param>
    /// <param name="content">弹窗提示内容</param>
    public DropdownButtonItem(string text, Func<Task> confirm, string content) : this(text, confirm)
    {
        IsConfirmButton = true;
        Content = content;
    }

    /// <summary>
    /// 确认弹窗按钮
    /// </summary>
    /// <param name="icon">实际按钮渲染图标</param>
    /// <param name="text">按钮显示值</param>
    /// <param name="confirm"></param>
    /// <param name="content">弹窗提示内容</param>
    public DropdownButtonItem(string icon, string text, Func<Task> confirm, string content)
        : this(text, confirm, content)
        => Icon = icon;

    /// <summary>
    /// 确认弹窗按钮
    /// </summary>
    public bool IsConfirmButton { get; set; } = false;

    /// <summary>
    /// 确认回调方法/普通按钮单击事件
    /// </summary>
    public Func<Task>? OnConfirm { get; set; }
    /// <summary>
    /// 关闭回调方法
    /// </summary>
    public Func<Task>? OnClose { get; set; }

    /// <summary>
    /// 显示标题
    /// </summary>
    public string? Title { get; set; }

    /// <summary>
    /// 显示文字
    /// </summary>
    public string? Content { get; set; }

    /// <summary>
    /// 确认按钮颜色
    /// </summary>
    public Color CloseButtonColor { get; set; } = Color.Secondary;

    /// <summary>
    /// 关闭按钮显示文字
    /// </summary>
    public string? CloseButtonText { get; set; }

    /// <summary>
    /// 确认按钮显示文字
    /// </summary>
    public string? ConfirmButtonText { get; set; }

    /// <summary>
    /// 确认按钮颜色
    /// </summary>
    public Color ConfirmButtonColor { get; set; } = Color.Primary;

    /// <summary>
    /// 确认框图标
    /// </summary>
    public string ConfirmIcon { get; set; } = "fa-exclamation-circle text-info";
}
